#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

using pii = pair < int , int >;
using vec = vector < int >;
using veg = vector < pii >;
using ll = long long;
using db = double;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 1e5 + 10;

int n,a[N];

void solve() {
	n = in;
	for(int i = 1;i <= n;i++) a[i] = in;
	int cnt0 = 0,cnt1 = 0,cnt2 = 0,cnt3 = 0;
	for(int i = 1;i <= n;i++) {
		if(a[i] == 0) cnt0++;
		if(a[i] == 1) cnt1++;
		if(a[i] == -1) cnt2++;
		if(abs(a[i]) > 1) cnt3++;
	}
	if(cnt3 > 1) return puts("0"),void();
	if(cnt2 == 1) { puts(cnt3 ? "0" : "1"); return; }
	if(cnt2 >= 1) { if(cnt3) return puts("0"),void(); if(cnt1 == 0) return puts("0"),void(); puts("1"); return; }
	puts("1");
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    for(int T = in;T;T--) solve();
}
